import { ref } from 'vue'
import { defineStore } from 'pinia'
export const useUserStore = defineStore(
  'BDC-user',
  () => {
    // 保存登录时的 token
    const token = ref('')
    const setToken = (newToken) => {
      token.value = newToken
      // console.log(token.value)
    }

    // 获取用户信息
    const user = ref({})
    const getUser =  (info) => {
      user.value = info
    }

    // 清空token
    const clearToken = () => {
      token.value = ''
    }
    return {
      setToken,
      getUser,
      user,
      token,
      clearToken,
    }
  },
  // 持久化创建开启
  {
    persist: true
  }
)
